import BaseAd from "../base/BaseAd";
import { SDKDir } from "../../SDKDefine";
export default abstract class BaseBannerAd extends BaseAd {
    protected rx: number = 1;
    protected ry: number = 1;
    protected height: number = 100;
    protected width: number = 300;
    protected dir: SDKDir = SDKDir.BOTTOM_MID;
    getStyle(): any {
        let winSize = this.sdk.getSystemInfoSync();
        let x = 0
        let y = 0
        switch (this.dir) {
            case SDKDir.BOTTOM_MID:
                x = (winSize.windowWidth - this.width) / 2
                y = winSize.windowHeight - this.height;
                break;
            case SDKDir.UP_MID:
                x = (winSize.windowWidth - this.width) / 2
                y = 0
                break;
            case SDKDir.MID:
                x = (winSize.windowWidth - this.width) / 2
                y = (winSize.windowHeight - this.height) / 2;
                break;
            case SDKDir.RIGHT_MID:
                x = (winSize.windowWidth - this.width)
                y = (winSize.windowHeight - this.height) / 2;
                break;
            case SDKDir.LEFT_TOP:
                x = 0
                y = 0
                break;
            case SDKDir.BOTTOM_LEFT:
                x = 0
                y = winSize.windowHeight - this.height;
                break;
            case SDKDir.XY:
                x = this.rx * winSize.windowWidth;
                y = this.ry * winSize.windowHeight;
                break;
            case SDKDir.WHITE:
                x = -this.width + 1
                y = -this.height + 1

                break;
        }
        // console.log('SGBannerAd getStyle x  ', x, 'y ', y, this._dir, this.width, this.height)
        return {
            left: x,
            top: y,
            width: this.width,
            height: this.height,
        }
    }

    updateSize() {
        if (!this.ad) {
            return;
        }
        let winSize = this.sdk.getSystemInfoSync();
        if (this.width != 0 && this.height != 0 && this.ad) {
            switch (this.dir) {
                case SDKDir.BOTTOM_LEFT:
                    this.ad.style.top = (winSize.windowHeight - this.height);
                    this.ad.style.left = 0;
                    break;
                case SDKDir.BOTTOM_MID:
                    this.ad.style.top = (winSize.windowHeight - this.height);
                    this.ad.style.left = (winSize.windowWidth - this.width) / 2;
                    break;
                case SDKDir.RIGHT_MID:
                    this.ad.style.top = (winSize.windowHeight - this.height) / 2;
                    this.ad.style.left = winSize.windowWidth - this.width;
                    break;
                case SDKDir.MID:
                    this.ad.style.top = (winSize.windowHeight - this.height) / 2;
                    this.ad.style.left = (winSize.windowWidth - this.width) / 2;
                    break;
                case SDKDir.TOP_MID:
                    this.ad.style.top = 0;
                    this.ad.style.left = (winSize.windowWidth - this.width) / 2;
                    break;
                case SDKDir.XY:
                    this.ad.style.top = this.ry * winSize.windowHeight;
                    this.ad.style.left = this.rx * winSize.windowWidth;
                    break;
            }

        }
    }

}